<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center forgotPassword_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub forgotPassword_fd0_0'>
          <view class='flex flex-wrap align-center forgotPassword_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  forgotPassword_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='forgotPassword_fd0_0_c1_c0'>{{$t('忘记密码')}}</text>
          </view>
          <view class='flex flex-wrap align-center justify-end forgotPassword_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex benben-flex-layout flex-wrap align-center forgotPassword_flex_1">
        <image class='forgotPassword_fd1_0' mode="aspectFit" :src='STATIC_URL+"3.png"'></image>
      </view>

      <!---flex布局flex布局结束-->
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout forgotPassword_flex_2">
        <view class='flex flex-wrap align-center forgotPassword_fd2_0'>
          <image class='forgotPassword_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"72.png"'></image>
          <input class='flex-sub' type="text" :placeholder="$t('请输入账号')" confirm-type="done" :maxlength="-1"
            placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx" v-model="forgetObj.email" />
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd2_1'>
          <image class='forgotPassword_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"74.png"'></image>
          <input class='flex-sub' type="number" :placeholder="$t('请输入验证码')" confirm-type="done" :maxlength="4"
            placeholder-style="color:rgba(153, 153, 153, 1);font-size:32rpx" v-model="forgetObj.code" />
          <benben-send-verification-code ref="vCode1699580190725" class='forgotPassword_fd2_1_c2' after-text='後重新獲取'
            :before-text="$t('获取验证码')" type='3' :phone="forgetObj.email"></benben-send-verification-code>
        </view>
        <view class='flex flex-wrap align-center forgotPassword_fd2_2'>
          <image class='forgotPassword_fd2_0_c0' mode="aspectFit" :src='STATIC_URL+"73.png"'></image>
          <benben-flex-password-diy v-model="forgetObj.paswd"
            class-name="flex align-center flex forgotPassword_fd2_2_c1" :placeholder="$t('请输入密码（6~12位数字+字母）')"
            :maxlength="12" :default-type='true' placeholder-style="color:#999;font-size:32rpx">
            <template #show>
              <text class='fu-iconfont2  forgotPassword_fd2_2_c1_icon1' data-type="show">&#xE837;</text>
            </template>
            <template #hide>
              <text class='fu-iconfont2  forgotPassword_fd2_2_c1_icon2' data-type="hide">&#xEBCC;</text>
            </template>
          </benben-flex-password-diy>
        </view>
        <view class='flex flex-direction flex-wrap align-center forgotPassword_fd2_3'>
          <button class='forgotPassword_fd2_3_c0' @tap.stop="forgotPasswordFunc()">{{$t('确定')}}</button>
        </view>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import {
    validate
  } from '@/common/utils/validate.js'
  export default {
    components: {},


    data() {
      return {
        "forgetObj": {
          "email": "",
          "code": "",
          "paswd": ""
        }
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      //切换语言
      switchLanguageFunc(lagun) {
        this.$store.commit('setLocale', {
          "locale": lagun
        })
      },
      //忘记密码
      async forgotPasswordFunc() {
        if (!validate(this.forgetObj.email, 'require')) {
          this.$message.info('请输入账号');
          return false;
        }
        // if (!validate(this.forgetObj.email, 'email')) {
        //   this.$message.info('请输入正确的邮箱号');
        //   return false;
        // }
        if (!validate(this.forgetObj.code, 'require')) {
          this.$message.info('验证码不能为空');
          return false;
        }
        if (!validate(this.forgetObj.code, 'captcha')) {
          this.$message.info('请输入正确的验证码');
          return false;
        }
        if (!validate(this.forgetObj.paswd, 'require')) {
          this.$message.info('密码不能为空');
          return false;
        }
        if (!validate(this.forgetObj.paswd, 'password')) {
          this.$message.info('请输入新密码（6~12位字母+数字）');
          return false;
        }
        //请求方法
        //数据验证

        let data5caeeba9866aa = await this.$api.post(global.apiUrls.post5caeeba9866aa, {
          password: this.forgetObj.paswd,
          account: this.forgetObj.email,
          code: this.forgetObj.code,
          type: '2',
          account_type: 'account'
        });

        if (data5caeeba9866aa.data.code != 1) {
          this.$message.info(data5caeeba9866aa.data.msg);
          return
        }



        this.$message.info('修改成功');
        setTimeout(() => {
          this.$urouter.redirectTo(`/pages/tabBar/loginPage/loginPage`);
        }, 500)
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: url(image-path('2.png')) no-repeat, #FFFFFF;
    background-size: 100% auto;
  }

  .forgotPassword_flex_0 {
    background: url(image-path('2.png')) no-repeat;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto;
  }

  .forgotPassword_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333;
    line-height: 88rpx;
  }

  .forgotPassword_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .forgotPassword_fd0_0_c0 {
    width: 195rpx;
  }

  .forgotPassword_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .forgotPassword_flex_1 {
    margin: 67rpx 0rpx 0rpx 0rpx;
  }

  .forgotPassword_fd1_0 {
    width: 412rpx;
    height: 120rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 0rpx 0rpx 32rpx;
  }

  .forgotPassword_flex_2 {
    margin: 88rpx 0rpx 0rpx 0rpx;
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .forgotPassword_fd2_3_c0 {
    background: #0181FF;
    border-radius: 24rpx 24rpx 24rpx 24rpx;
    width: 686rpx;
    line-height: 96rpx;
    font-size: 32rpx;
    color: #fff;
    height: 96rpx;
    box-shadow: 0rpx 10rpx 20rpx 1rpx rgba(1, 129, 255, 0.2);
  }

  .forgotPassword_fd2_3 {
    margin: 64rpx 0rpx 0rpx 0rpx;
  }

  .forgotPassword_fd2_2_c1_icon2 {
    width: 88rpx;
    line-height: 88rpx;
    text-align: center;
    font-size: 40rpx;
  }

  .forgotPassword_fd2_2_c1_icon1 {
    text-align: center;
    font-size: 40rpx;
  }

  ::v-deep .forgotPassword_fd2_2_c1 {
    font-size: 32rpx;
    width: 566rpx;
    height: 50rpx;
  }

  .forgotPassword_fd2_2 {
    background: rgba(255, 255, 255, 1);
    border-radius: 24rpx;
    background-size: 100% auto;
    padding: 24rpx;
    margin: 32rpx 0rpx 0rpx 0rpx;
  }

  .forgotPassword_fd2_1_c2 {
    line-height: 44rpx;
    text-align: center;
    font-size: 32rpx;
    color: #0181FF;
    font-weight: 400;
  }

  .forgotPassword_fd2_1 {
    background: rgba(255, 255, 255, 1);
    margin: 32rpx 0rpx 0rpx 0rpx;
    border-radius: 24rpx;
    background-size: 100% auto;
    padding: 24rpx;
  }

  .forgotPassword_fd2_0_c0 {
    width: 40rpx;
    height: 40rpx;
    border-radius: 0rpx 0rpx 0rpx 0rpx;
    margin: 0rpx 16rpx 0rpx 0rpx;
  }

  .forgotPassword_fd2_0 {
    background: rgba(255, 255, 255, 1);
    border-radius: 24rpx;
    background-size: 100% auto;
    padding: 24rpx;
  }
</style>